package com.ayu.shortlink.project.dao.mapper;

import com.ayu.shortlink.project.dao.entiry.ShortLinkDO;
import com.ayu.shortlink.project.dto.req.ShortLinkPageReqDTO;
import com.ayu.shortlink.project.dto.req.ShortLinkRecycleBinPageReqDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;

public interface ShortLinkMapper extends BaseMapper<ShortLinkDO> {

    /**
     * 短链接访问自增
     */
    //@Update("UPDATE t_link SET total_uv = total_uv+#{totalUv},total_pv = total_pv+#{totalPv},total_uip = total_uip+#{totalUip} WHERE gid = #{gid} AND full_short_url = #{fullShortUrl};")
    void incrementStats(
            @Param("gid")String gid,
            @Param("fullShortUrl")String fullShortUrl,
            @Param("totalPv")Integer totalPv,
            @Param("totalUv")Integer totalUv,
            @Param("totalUip")Integer totalUip
    );

    /**
     * 短链接访问自增V2版本
     */
    void incrementStats2(
            @Param("gid")String gid,
            @Param("fullShortUrl")String fullShortUrl,
            @Param("totalPv")Integer totalPv,
            @Param("totalUv")Integer totalUv,
            @Param("totalUip")Integer totalUip
    );

    IPage<ShortLinkDO> pageLink(ShortLinkPageReqDTO requestParam);

    /**
     * 分页统计回收站短链接
     */
    IPage<ShortLinkDO> pageRecycleBinLink(ShortLinkRecycleBinPageReqDTO requestParam);
}
